package scorer;

import java.util.ArrayList;

import scorer.Dragon.DRAGON;
import scorer.Wind.WIND;

public abstract class Tile implements Comparable<Tile> {

	protected enum SUIT {
		Bamboo, Character, Dots, Wind, Dragon, Flower, Season,
	}

	protected enum VIEW {
		M, H, C, W,
	}

	public VIEW status;
	public Object value;
	public SUIT suit;

	public Tile(Object o) {
		value = o;
	}

	public Tile(Object o, SUIT s) {
		value = o;
		suit = s;
		status = VIEW.H;
	}

	public abstract Object getValue();

	public static boolean isValid(Object o) {
		return false;
	}

	public static ArrayList<Object> getValidValues() {
		return null;
	}

	public abstract String print();

	public int compareTo(Tile t) {
		if (t.status == status) {
			if (t.suit == suit) {
				if (t.value instanceof Integer) {
					return ((Integer) value).compareTo((Integer) t.value);
				}
				if (t.value instanceof WIND) {
					return ((WIND) value).compareTo((WIND) t.value);
				}
				if (t.value instanceof DRAGON) {
					return ((DRAGON) value).compareTo((DRAGON) t.value);
				}
			}
			return suit.compareTo(t.suit);
		}
		return status.compareTo(t.status);
	}

	public boolean equals(Object o) {
		return o instanceof Tile && ((Tile) o).suit == suit
				&& ((Tile) o).value.equals(value);
	}

	public abstract Tile clone();

	public String toString() {
		return (suit == SUIT.Dragon ? "D" : suit == SUIT.Wind ? "W" : suit
				.toString().substring(0, 1).toLowerCase())
				+ value.toString().substring(0, 1).toLowerCase();
	}

}
